/*
数据结构 解题报告：
http://git.oschina.net/et0662/sznoi-Data_Structure
*/
#include<stdio.h>

typedef struct _NODE
{
	char ch;
	struct _NODE* next;
}Node, *Stack;

//return c1>c2
int operationCMP(char c1,char c2)
{
	if((c2=='+'||c2=='-') && (c1=='*'||c1=='/'))
		return 1;
	else
		return 0;
}

void push(Stack s, char c)
{
	//printf("\n> %c\n",c);
	Node * p;
	if(s->next==NULL)
	{
		p=new Node;
		p->next=NULL;
		p->ch=c;
		s->next=p;
	}
	else
	{
		p=new Node;
		p->ch=c;
		p->next=s->next;
		s->next=p;
	}
}

char pop(Stack s)
{
	Node *p;
	char ch=0;
	if(s->next)
	{
		p=s->next;
		ch=p->ch;
		s->next=p->next;
		delete(p);
	}
	//printf("\n< %c\n",ch);
	return ch;
}

int main(void)
{
	char c;
	int a,b;
	Stack s;
	s=new Node;
	s->next=NULL;
	while( scanf("%c",&c)!=EOF)
	{
		if(c=='\x0d'||c=='\x0a')
			break;
		//数字直接输出
		if( '0'<=c && c<='9' )
			printf("%c ",c);
		else 
		{
			//栈为空就入栈
			if(s->next==NULL)
			{
				//printf("empty in\n");
				push(s,c);
			}
			else
			{
				//如果是开括空就直接入栈
				if(c=='(')
				{
					push(s,c);
				}
				else if(c==')') //如果是收括号，就匹配括号
				{
					while(c=pop(s),c!='(')
					{
						//printf(") out\n");
						printf("%c ",c);
					}
				}else{
					if(s->next->ch=='(')
					{
						push(s,c);
					}
					else
					{
						//输入的操作符不高于，栈内运算符，就依次弹出
						while(s->next&& (!operationCMP(c,s->next->ch)))
						{
							printf("%c ",pop(s));
						}
						push(s,c);
					}
				}
			}
		}
		
	}
	while(s->next)
	{
		printf("%c ", pop(s));
	}
	return 0;
}
